package com.iotteam.androidbase.commen.views.charts.line;

import com.iotteam.androidbase.commen.views.charts.Axis;
import com.iotteam.androidbase.commen.views.charts.Point;

/**
 * Created by vonchenchen on 16/08/2017.
 */

public class DefaultMapper implements ILocationMapper {

    @Override
    public Point map(Data data, Axis xAxis, Axis yAxis) {

        Point point = new Point();

        Axis.AxisComputerInfo xInfo = xAxis.getAxisComputerInfo();
        Axis.AxisComputerInfo yInfo = yAxis.getAxisComputerInfo();

        point.x = (data.xData * (xInfo.mMax - xInfo.mMin)) * xInfo.mTotleLen + xAxis.getAxisComputerInfo().mMargin;
        point.y = (1 - data.yData * (yInfo.mMax - yInfo.mMin)) * yInfo.mTotleLen - yAxis.getAxisComputerInfo().mMargin;

        return point;
    }
}
